1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
13 namespace SuperPolarity
16 /// This is the main type for your game
18 public class SuperPolarity : Game
20 GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
25 public SuperPolarity()
28 graphics = new GraphicsDeviceManager(this);
29 Content.RootDirectory = "Content";
33 /// Allows the game to perform any initialization it needs to before starting to run.
34 /// This is where it can query for any required services and load any non-graphic
35 /// related content. Calling base.Initialize will enumerate through any components
36 /// and initialize them as well.
38 protected override void Initialize()
40 player = new MainShip();
46 /// LoadContent will be called once per game and is the place to load
47 /// all of your content.
49 protected override void LoadContent()
51 // Create a new SpriteBatch, which can be used to draw textures.
52 spriteBatch = new SpriteBatch(GraphicsDevice);
54 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
56 player.Initialize(Content.Load<Texture2D>("Graphics\\player"), playerPosition);
60 /// UnloadContent will be called once per game and is the place to unload
63 protected override void UnloadContent()
65 // TODO: Unload any non ContentManager content here
69 /// Allows the game to run logic such as updating the world,
70 /// checking for collisions, gathering input, and playing audio.
72 /// <param name="gameTime">Provides a snapshot of timing values.</param>
73 protected override void Update(GameTime gameTime)
75 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
78 // TODO: Add your update logic here
80 base.Update(gameTime);
84 /// This is called when the game should draw itself.
86 /// <param name="gameTime">Provides a snapshot of timing values.</param>
87 protected override void Draw(GameTime gameTime)
89 GraphicsDevice.Clear(Color.CornflowerBlue);
93 player.Draw(spriteBatch);